package org.yefei.homeworkday24;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Scanner;

public class Five {
	public static void main(String[] args) {
		// 5：通过控制台输入字符，如果输入的是quit,则退出,否则继续输入;把输入的字符写入文件保存。
		Scanner in = new Scanner(System.in);
		String input = null;
		OutputStream o = null;
		try {
			o = new FileOutputStream("F:\\叶飞io测试\\写入\\all.txt");
			while (true) {
				System.out.println("输入字符：");
				input = in.next();
				byte[] b = input.getBytes();
				o.write(b, 0, b.length);
				if (input.equals("quit")) {
					break;
				} else {
					continue;
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (o != null)
				try {
					o.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
		}

	}
}
